package com.bugsnag.ohos;

/**
 * ErrorTypes
 *
 * @since 2021-07-01
 */
public class ErrorTypes {
    /**
     * Sets whether [ANRs]
     * should be reported to Bugsnag.
     * <p>
     * If you wish to disable ANR detection, you should set this property to false.
     */
    boolean anrs = true;

    /**
     * Determines whether NDK crashes such as signals and exceptions should be reported by bugsnag.
     * <p>
     * This flag is true by default.
     */
    boolean ndkCrashes = true;

    /**
     * Sets whether Bugsnag should automatically capture and report unhandled errors.
     * By default, this value is true.
     */
    boolean unhandledExceptions = true;

    /**
     * Sets whether Bugsnag should automatically capture and report unhandled promise rejections.
     * This only applies to React Native apps.
     * By default, this value is true.
     */
    boolean unhandledRejections = true;

    /**
     * constructor
     */
    public ErrorTypes() {
        this(true, true, true, true);
    }

    /**
     * constructor
     *
     * @param anrs
     * @param ndkCrashes
     * @param unhandledExceptions
     * @param unhandledRejections
     */
    public ErrorTypes(boolean anrs, boolean ndkCrashes, boolean unhandledExceptions, boolean unhandledRejections) {
        this.anrs = anrs;
        this.ndkCrashes = ndkCrashes;
        this.unhandledExceptions = unhandledExceptions;
        this.unhandledRejections = unhandledRejections;
    }

    /**
     * constructor
     *
     * @param detectErrors
     */
    public ErrorTypes(boolean detectErrors) {
        this(detectErrors, detectErrors, detectErrors, detectErrors);
    }

    /**
     * copy error types
     *
     * @return ErrorTypes
     */
    public ErrorTypes copy() {
        return new ErrorTypes(anrs, ndkCrashes, unhandledExceptions, unhandledRejections);
    }

    public boolean getAnrs() {
        return anrs;
    }

    public void setAnrs(boolean anrs) {
        this.anrs = anrs;
    }

    public boolean getNdkCrashes() {
        return ndkCrashes;
    }

    public void setNdkCrashes(Boolean ndkCrashes) {
        this.ndkCrashes = ndkCrashes;
    }

    public boolean getUnhandledExceptions() {
        return unhandledExceptions;
    }

    public void setUnhandledExceptions(boolean unhandledExceptions) {
        this.unhandledExceptions = unhandledExceptions;
    }

    public boolean getUnhandledRejections() {
        return unhandledRejections;
    }

    public void setUnhandledRejections(boolean unhandledRejections) {
        this.unhandledRejections = unhandledRejections;
    }
}
